home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / libsrc11.arc / MODS.S < prev    next >
Text File  |  1989-04-27  |  1KB  |  51 lines

  1. ******************************************************************************
  2. * mods.s 3.1 11/12/84 
  3. *
  4. *        68HC11 CROSS C COMPILER RUN-TIME LIBRARY
  5. *
  6. *           (c) Copyright 1984, Motorola, Inc.
  7. *
  8. *  FUNCTION NAME:    .mods
  9. *
  10. *  ACTION:        Calculate the modulus of two 8-bit signed integers.
  11. *
  12. *  REGISTERS AND STACK:
  13. *
  14. *  ON ENTRY:    X:    FP (frame pointer)
  15. *        B:    Dividend
  16. *        A:    Divisor
  17. *
  18. *        STACK:      Return Address
  19. *        SP:    
  20. *
  21. *  ON EXIT:    X:    FP 
  22. *        B:    Modulus
  23. *
  24. *        STACK:    Previous Contents
  25. *        SP:    
  26. *
  27. ******************************************************************************
  28.     psct
  29.     xdef    .mods
  30. .mods:
  31.     pshx        save FP
  32.     tsta        is divisor > 0?
  33.     bpl    *+3    yes
  34.     nega        no..negate
  35.     psha        copy..
  36.     clra        ..divisor
  37.     psha        ..to
  38.     pulx        ..X
  39.     pshb        save sign of dividend
  40.     tstb        is dividend > 0?
  41.     bpl    *+3    yes
  42.     negb        no..negate
  43.     idiv        do division D/X
  44.     pula        recover sign
  45.     tsta        is sign positive?
  46.     bpl    *+3    yes
  47.     negb        no..negate remainder
  48.     pulx        restore FP
  49.     rts        return
  50.     end
  51.